home *** CD-ROM | disk | FTP | other *** search
-
- #include "BuildControl.h"
-
-
-
- #if defined(qUseDumpFile)
- #include "DumpHeader.h"
- #else
- #include <Resources.h>
- #endif
-
- #include "AESupport.h"
-
- struct AEHandler {
- AEEventClass aeClass;
- AEEventID aeID;
- AEEventHandlerProcPtr aeProc;
- };
- typedef struct AEHandler AEHandler;
-
- enum {kNumOfAEHandlers = 4};
-
-
-
- static AEDesc pSelfTarget;
- extern Boolean gDone;
-
- //----------------------------------------------------------------------------
- // CreateAETarget
- //----------------------------------------------------------------------------
- #pragma segment AESupport
- OSErr CreateAETarget(ProcessSerialNumber *targetPSN, AEDesc *targetDesc)
- {
- return AECreateDesc(typeProcessSerialNumber, (Ptr) targetPSN,
- sizeof(ProcessSerialNumber), targetDesc);
- }
-
- //----------------------------------------------------------------------------
- // InitAppleEventsStuff
- //----------------------------------------------------------------------------
- #pragma segment Initialize
- void InitAESupport(void)
- {
- ProcessSerialNumber targetPSN;
- OSErr err;
- AEEventHandlerUPP eventProc;
- short index;
- AEHandler *theHandler, aeHandler[kNumOfAEHandlers] =
- {{kCoreEventClass, kAEOpenApplication, (AEEventHandlerProcPtr) DoAEOpenApplication},
- {kCoreEventClass, kAEOpenDocuments, (AEEventHandlerProcPtr) DoAEOpenDocuments},
- {kCoreEventClass, kAEPrintDocuments, (AEEventHandlerProcPtr) DoAEPrintDocuments},
- {kCoreEventClass, kAEQuitApplication, (AEEventHandlerProcPtr) DoAEQuitApplication}};
-
- for (index = 0; index < kNumOfAEHandlers; index ++) {
- theHandler = &aeHandler[index];
- eventProc = NewAEEventHandlerProc(theHandler->aeProc);
- err = AEInstallEventHandler(theHandler->aeClass,
- theHandler->aeID, eventProc, 0, false);
-
- if (err != noErr) {
- gDone = true;
- index = kNumOfAEHandlers;
- }
- }
- (void) GetCurrentProcess(&targetPSN);
- err = CreateAETarget(&targetPSN, &pSelfTarget);
- }
-
- //----------------------------------------------------------------------------
- // DoAEOpenApplication
- //----------------------------------------------------------------------------
- #pragma segment AESupport
- pascal OSErr DoAEOpenApplication(AppleEvent * ae, AppleEvent * reply, long refCon)
- {
- #pragma unused (ae, reply, refCon)
- return noErr;
- }
-
- //----------------------------------------------------------------------------
- // DoAEOpenDocuments
- //----------------------------------------------------------------------------
- #pragma segment AESupport
- pascal OSErr DoAEOpenDocuments(AppleEvent * ae, AppleEvent * reply, long refCon)
- {
- #pragma unused (ae, reply, refCon)
- return errAEEventNotHandled;
- }
-
- //----------------------------------------------------------------------------
- // DoAEPrintDocuments
- //----------------------------------------------------------------------------
- #pragma segment AESupport
- pascal OSErr DoAEPrintDocuments(AppleEvent * ae, AppleEvent * reply, long refCon)
- {
- #pragma unused (ae, reply, refCon)
- return errAEEventNotHandled;
- }
-
- //----------------------------------------------------------------------------
- // DoAEQuitApplication
- //----------------------------------------------------------------------------
- #pragma segment AESupport
- pascal OSErr DoAEQuitApplication(AppleEvent * ae, AppleEvent * reply, long refCon)
- {
- #pragma unused (ae, reply, refCon)
- gDone = true;
- return noErr;
- }